<template>
	<view class="personalPage">
		 <view class="uni-list-cell cell1" hover-class="uni-list-cell-hover" v-if="authStatus !='checking'" @click='jump'>
				 <view class="trueName">
						<view class="left">
							实名认证
						</view>
						
						<view class="right"> 
						<text class="red" v-if="!authTime">{{statusText}}</text>
						<view v-if="authTime">
							<view class="bj_red">
								<i class='iconfont'>&#xe611;</i>
								已实名
							</view>
							<view class="name">
									{{name}}
							</view>
							
						</view>
						<uni-icon type="arrowright" size='20' color='#999999'></uni-icon>
						</view>
				 
				 </view>
			 
		 		
         </view>
		 <view class="uni-list-cell cell1" hover-class="uni-list-cell-hover" v-if="authStatus==='checking'">
				 <view class="trueName">
						<view class="left">
							实名认证
						</view>
						<view class="right"> 
						<text class="red" >审核中</text>
						</view>
				 </view>
			 
		 		
         </view>
		 <view class="uni-list-cell">
				<view class="trueName mobile">

					 <view class="left">
						手机号
					 </view>
					<view class="mobileText">{{mobile}}</view>
				</view>

         </view>
	</view>
</template>

<script>
import uniIcon from '@/components/uni-icon.vue';
var util = require('../../common/util.js');
export default {
    data() {
        return {
            statusText: '去认证',
            name: '',
            mobile: '',
            idNumber: '',
            name_: '',
            authStatus: '',
            authTime: ''
        };
    },
    onLoad() {
        this.getUserInfo();
    },
    methods: {
        jump() {
            if (this.authTime === 0) {
                if (this.authStatus === 'checking') {
                    uni.navigateTo({
                        url: './toCertification3'
                    });
                } else {
                    uni.navigateTo({
                        url: './toCertification'
                    });
                }
            } else {
                uni.navigateTo({
                    url:
                        './trueNameAuthentication?name=' + this.name_ + '&idNumber=' + this.idNumber
                });
            }
        },

        getUserInfo() {
            util.ajax(
                'userCenter',
                {
                    token: util.getUserToken()
                },
                data => {
                    let json = data.data;
                    if (json.status) {
                        // console.log(json)
                        this.authStatus = json.data.authStatus.value;
                        this.authTime = json.data.authTime;
                        let mobile = json.data.mobile;
                        let idNumber = json.data.idNumber;
                        this.name_ = json.data.name;

                        this.name = '*' + this.name_.substr(this.name_.length - 1);
                        this.mobile =
                            mobile.substr(0, 3) + '****' + mobile.substr(mobile.length - 4, 4);
                        if (json.data.idNumber) {
                            this.idNumber =
                                idNumber.substr(0, 3) +
                                '***********' +
                                idNumber.substr(idNumber.length - 4, 4);
                        }
                    } else {
                        uni.showToast({
                            title: json.message,
                            icon: 'none',
                            duration: 1000
                        });
                    }
                },
                (data, code) => {
                    // console.log(data);
                    uni.showToast({
                        title: JSON.stringify(data.message),
                        icon: 'none',
                        duration: 1000
                    });
                }
            );
        }
    },
    components: {
        uniIcon
    }
};
</script>

<style lang="less">
// 	page{
// 		background: white;
// 	}
.uni-list-cell:after {
    background-color: white;
}
.personalPage {
    flex: 1;
    flex-direction: column;
    width: 100%;
	.cell1{
		border-top: 1upx solid #eeeeee;
	}
    .uni-list-cell {
        background: white;
        height: 122upx;
        padding: 0 30upx;
        
        .trueName {
            width: 100%;
            height: 100%;
			justify-content: space-between;
			align-items: center;
			.left{
				font-size: 30upx;
				color: #000000;
			}
            .right {
                align-items: center;
                .bj_red {
                    background: #ff1268;
                    color: white;
                    padding: 10upx;
                    margin-right: 10upx;
                    border-radius: 6upx;
                    font-size: 22upx;
                    line-height: 1;
                    align-items: center;
                    i {
                        font-size: 22upx;
                        display: flex;
                        align-items: center;
                        margin-right: 10upx;
                    }
                }
                .name {
                    align-items: center;
					font-size: 30upx;
					color: #999999;
                }
                .red {
                    color: #ff1268;
                }
            }
			
        }
		.mobile{
			border-top: 1upx solid #eeeeee;
			.mobileText{
				font-size: 30upx;
				color: #999999;
				margin-right: 38upx;
			}
			
		}
    }
}
</style>
